﻿<%
class MoLibSafeCode
	Private vVersion
	 
	Public Property Get Version()
	   Version = vVersion
	 End Property
	 
	 Private Sub Class_Initialize()
		vVersion = "Safe Code 8.12.14"
	 End Sub
	
	Public Sub Code(ByVal sessionKey)
	Response.Buffer = True
	Response.Expires = -1
	Response.AddHeader "Pragma", "no-cache"
	Response.AddHeader "cache-ctrol", "no-cache"
	Response.ContentType = "Image/bmp"
	Randomize
	Dim I, ii, iii,cOdds,cAmount,cCode
	cOdds = 0
	cAmount = 56
	Dim vColorData(6)
	vColorData(0) = ChrB(&H0) & ChrB(&H0) & ChrB(&HFF) 
	vColorData(1) = ChrB(&HFF) & ChrB(&HFF) & ChrB(&HFF)
	vColorData(2) = ChrB(&HFF) & ChrB(&HFF) & ChrB(&HFF)
	vColorData(3) = ChrB(0) & ChrB(0) & ChrB(255)
	vColorData(4) = ChrB(0) & ChrB(102) & ChrB(0)
	vColorData(5) = ChrB(255) & ChrB(0) & ChrB(0)
	vColorData(6) = ChrB(0) & ChrB(0) & ChrB(0)
	cCode = "0123456789aAcCeEmMnNrRsSuUvVwWxXzZjJbBdDfFhHkKtTgGpPqQyY"
	Dim vNumberData(55)
	vNumberData(0) = "1110001111110111011111011101111101110111110111011111011101111101110111110111011111100011111111111111"
	vNumberData(1) = "1111011111111001111111110111111111011111111101111111110111111111011111111101111111100011111111111111"
	vNumberData(2) = "1110001111110111011111011101111111110111111110111111110111111110111111110111111111000001111111111111"
	vNumberData(3) = "1110001111110111011111111101111111001111111111011111111101111111110111110111011111100011111111111111"
	vNumberData(4) = "1111101111111100111111101011111101101111110110111110111011111100001111111110111111110001111111111111"
	vNumberData(5) = "1100000111110111111111011111111100001111110111011111111101111101110111110111011111100011111111111111"
	vNumberData(6) = "1111000111111011011111011111111101001111110011011111011101111101110111110111011111100011111111111111"
	vNumberData(7) = "1100000111110110111111111011111111101111111101111111110111111111011111111101111111110111111111111111"
	vNumberData(8) = "1110001111110111011111011101111110101111111000111111011101111101110111110111011111100011111111111111"
	vNumberData(9) = "1110001111110111011111011101111101110111110110011111100101111111110111110110111111000111111111111111"
	vNumberData(10) = "1111111111111111111111100011111101110111111100011111101101111101110111111000001111111111111111111111"
	vNumberData(11) = "1111011111111101111111101011111110101111111010111111100011111101110111110111011110001000111111111111"
	vNumberData(12) = "1111111111111111111111100001111101110111110111111111011111111101110111111000111111111111111111111111"
	vNumberData(13) = "1110000111110111011110111111111011111111101111111110111111111011111111110111011111100011111111111111"
	vNumberData(14) = "1111111111111111111111100011111101110111110000011111011111111101110111111000111111111111111111111111"
	vNumberData(15) = "1000000111110111011111011111111101101111110000111111011011111101111111110111011110000001111111111111"
	vNumberData(16) = "1111111111111111111110000011111101010111110101011111010101111101010111100101001111111111111111111111"
	vNumberData(17) = "1000100011110010011111001001111100100111110101011111010101111101010111110101011110010100111111111111"
	vNumberData(18) = "1111111111111111111110010011111100110111110111011111011101111101110111100011001111111111111111111111"
	vNumberData(19) = "1000100011110011011111001101111101010111110101011111010101111101100111110110011110001101111111111111"
	vNumberData(20) = "1111111111111111111111001001111110011111111011111111101111111110111111110000111111111111111111111111"
	vNumberData(21) = "1000001111110111011111011101111100001111110101111111011011111101101111110111011110001100111111111111"
	vNumberData(22) = "1111111111111111111111100001111101110111111001111111111011111101110111110000111111111111111111111111"
	vNumberData(23) = "1110000111110111011111011111111110111111111100111111111101111111110111110111011111000011111111111111"
	vNumberData(24) = "1111111111111111111110011001111101110111110111011111011101111101110111111000001111111111111111111111"
	vNumberData(25) = "1000100011110111011111011101111101110111110111011111011101111101110111110111011111100011111111111111"
	vNumberData(26) = "1111111111111111111110001000111101110111110111011111101011111110101111111101111111111111111111111111"
	vNumberData(27) = "1000100011110111011111011101111110101111111010111111101011111110101111111101111111110111111111111111"
	vNumberData(28) = "1111111111111111111110010100111101010111110101011111010101111110101111111010111111111111111111111111"
	vNumberData(29) = "1001010011110101011111010101111101010111110101011111001001111110101111111010111111101011111111111111"
	vNumberData(30) = "1111111111111111111110010001111101101111111001111111100111111101101111100010011111111111111111111111"
	vNumberData(31) = "1001000111110110111111011011111110011111111001111111100111111101101111110110111110001001111111111111"
	vNumberData(32) = "1111111111111111111111000001111101101111111101111111110111111110110111110000011111111111111111111111"
	vNumberData(33) = "1100000111110110111111111011111111011111111101111111110111111110111111111011011111000001111111111111"
	vNumberData(34) = "1111111111111111111111100011111111101111111110111111111011111111101111111110111111111011111100011111"
	vNumberData(35) = "1100000111111101111111110111111111011111111101111111110111111111011111111101111110110111111000111111"
	vNumberData(36) = "1001111111110111111111011111111100001111110111011111011101111101110111110111011111000011111111111111"
	vNumberData(37) = "1000001111110111011111011101111100001111110111011111011101111101110111110111011110000011111111111111"
	vNumberData(38) = "1111100111111111011111111101111110000111110111011111011101111101110111110111011111100000111111111111"
	vNumberData(39) = "1000011111110110111111011101111101110111110111011111011101111101110111110110111110000111111111111111"
	vNumberData(40) = "1111000111111011011111101111111000001111111011111111101111111110111111111011111111000011111111111111"
	vNumberData(41) = "1000000111110111011111011111111101101111110000111111011011111101111111110111111110001111111111111111"
	vNumberData(42) = "1001111111110111111111011111111101001111110011011111011101111101110111110111011110001100111111111111"
	vNumberData(43) = "1000100011110111011111011101111101110111110000011111011101111101110111110111011110001000111111111111"
	vNumberData(44) = "1001111111110111111111011111111101000111110110111111010111111100011111110110111110001001111111111111"
	vNumberData(45) = "1000100111110110111111010111111100111111110001111111010111111101101111110110111110001001111111111111"
	vNumberData(46) = "1111111111111011111111101111111000001111111011111111101111111110111111111011111111110011111111111111"
	vNumberData(47) = "1100000111110101011111110111111111011111111101111111110111111111011111111101111111100011111111111111"
	vNumberData(48) = "1111111111111000011111011011111101101111111001111111011111111100001111110111011111100011111111111111"
	vNumberData(49) = "1110001111110110111110111111111011111111101111111110110001111011101111110110111111100111111111111111"
	vNumberData(50) = "1111111111100000111111011101111101110111110111011111011101111100001111110111111110001111111111111111"
	vNumberData(51) = "1000001111110111011111011101111101110111110000111111011111111101111111110111111110001111111111111111"
	vNumberData(52) = "1111111111111000011111011101111101110111110111011111011101111110000111111111011111111000111111111111"
	vNumberData(53) = "1110011111110110111110111101111011110111101111011110111101111010010111110110111111100011111111100111"
	vNumberData(54) = "1111111111100010001111011101111110101111111010111111110111111111011111111011111110001111111111111111"
	vNumberData(55) = "1000100011110111011111101011111110101111111101111111110111111111011111111101111111100011111111111111"


	Dim vCode(4), vCodes
	For I = 0 To 3
		vCode(I) = Int(Rnd * cAmount)
		vCodes = vCodes & Mid(cCode, vCode(I) + 1, 1)
	Next
	Session(sessionKey) = vCodes

	Response.BinaryWrite ChrB(66) & ChrB(77) & ChrB(230) & ChrB(4) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(54) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(40) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(40) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(10) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(1) & ChrB(0)

	Response.BinaryWrite ChrB(24) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(176) & ChrB(4) & ChrB(0) & ChrB(0) & ChrB(18) & ChrB(11) & ChrB(0) & ChrB(0) & ChrB(18) & ChrB(11) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0)
	For I = 9 To 0 Step -1
	For ii = 0 To 3
	For iii = 1 To 10
	If Rnd * 99 + 1 < cOdds Then
		Response.BinaryWrite getrndcolor()
	Else
		if Mid(vNumberData(vCode(ii)), I * 10 + iii, 1) = 0 Then 
			Response.BinaryWrite getrndcolor()
		Else
			Response.BinaryWrite vColorData(1)
		End If
	End If
	Next
	Next
	Next
	End Sub
	private function getrndcolor()
		getrndcolor = chrb(int(rnd()*128)) & chrb(int(rnd()*128)) & chrb(int(rnd()*128))
	End function
End Class
%>